<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>密码修改</title>
    <meta name="description" content="particles.js is a lightweight JavaScript library for creating particles.">
    <meta name="author" content="Vincent Garreau"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" media="screen" href="css/style_resetPW.css">
    <link rel="stylesheet" type="text/css" href="css/reset.css"/>
    <style>
        #login_button {
            margin: 0;
            padding: 0;
            border: 1px solid transparent;
            outline: none;
            background-color: #1E90FF;
            cursor: pointer;
            color: #ffffff;
        }

        #login_img {
            text-align: center;
        }

        #login_img img {
            margin-top: 30px;
        }

        #validateCodeButton {
            margin-top: 10px;
            margin-left: 10px;
            border-radius: 5px;

        }
    </style>
    <link rel="stylesheet" href="plugins/elementui/index.css"/>
    <script src="js/jquery.min.js"></script>
    <script src="js/healthmobile.js"></script>
    <script src="js/vue.js"></script>
    <script src="js/axios-0.18.0.js"></script>
    <script src="plugins/elementui/index.js"></script>
</head>
<body>
<div id="app">
    <div id="particles-js">
        <form id='login-form' onsubmit="return false">
            <div class="login">
                <div id="login_img"><img src="img/loginLogo.png" alt=""></div>
                <div class="login-top">
                    密码修改
                </div>

                <!--<div class="login-center clearfix">
                    <div class="login-center-img">&lt;!&ndash;<img src="img/account.jpg"/>&ndash;&gt;</div>
                    <div class="login-center-input">
                        <input type="text" v-model="loginInfo.oldPassword" placeholder="请输入旧密码"
                               onfocus="this.placeholder=''"
                               onblur="this.placeholder='请输入旧密码'"/>
                        <div class="login-center-input-text">旧密码</div>
                    </div>
                </div>-->

                <div class="login-center clearfix">
                    <div class="login-center-img"><img src="img/name.png"/></div>
                    <div class="login-center-input">
                        <input id="account" v-model="loginInfo.account" readonly="readonly"/>
                        <div class="login-center-input-text">用户名</div>

                    </div>
                </div>
                <div class="login-center clearfix">
                    <div class="login-center-img"><img src="img/password.png"/></div>
                    <div class="login-center-input">
                        <input type="password" v-model="loginInfo.newPassword" placeholder="请输入新密码"
                               onfocus="this.placeholder=''"
                               onblur="this.placeholder='请输入新密码'"/>
                        <div class="login-center-input-text">新密码</div>
                    </div>
                </div>

                <div class="login-center clearfix">
                    <div class="login-center-img"><img src="img/password.png"/></div>
                    <div class="login-center-input">
                        <input type="password" v-model="loginInfo.newPassword2" placeholder="请确认新密码"
                               onfocus="this.placeholder=''"
                               onblur="this.placeholder='请确认新密码'"/>
                        <div class="login-center-input-text">确认新密码</div>
                    </div>
                </div>
                <div class="login-button"  @click="reset()">
                    <input type="button" id="login_button">确认</input>
                    <br>
                </div>

            </div>

            <div class="sk-rotating-plane"></div>
        </form>
    </div>
</div>

<script>


    var username = getUrlParam("username");


    var vue = new Vue({
        el: '#app',
        data: {

            loginInfo: {}//登录信息
        },

        created(){
            /*$("#account").val(username);*/

            this.loginInfo.account = username;
        },
        methods: {

            //修改密码
            reset() {

                if(this.loginInfo.newPassword != this.loginInfo.newPassword2){

                    this.$message.error("两次输入的密码不一致");

                    return false;
                }

                axios.post("/resetpassword/resetpw.do",this.loginInfo).then((response) => {
                    if(response.data.flag){
                        //验证成功,跳转到修改密码页面
                        alert(response.data.message)
                        window.location.href="login.html";
                    }else{
                        //失败，提示失败信息
                        this.$message.error(response.data.message);
                    }
                });
            }
        }
    });
</script>

<!-- scripts -->
<script src="js/particles.min.js"></script>
<script src="js/app.js"></script>
<script type="text/javascript">

</script>
</body>
</html>